package com.orafl.use.comorafluse.definition;

import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;

public class definitionMain {
    public static void main(String[] args) {
        //这个是不是个 spring 的bean了 ？
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition("com.orafl.use.comorafluse.definition.KingUser");
        builder.addPropertyValue("name","国王");
        AbstractBeanDefinition beans = builder.getBeanDefinition();
        beans.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
        System.out.println(beans);


        // 答案这个还不是 ： 他还是指一个模型，还需要加工！
        System.out.println("**************************************************");
        System.out.println("**************************************************");

        GenericBeanDefinition builder2 = new GenericBeanDefinition();
        builder2.setBeanClass(KingUser.class);
        MutablePropertyValues propertyValues =new MutablePropertyValues();
        propertyValues.add("name","欧拉吉吉国王");
        builder2.setPropertyValues(propertyValues);
        System.out.println(builder2);




        //System.out.println(builder2.getClass().toString());

        //BeanDefinitionBuilder.rootBeanDefinition();


        //BeanNameGenerator    --- DefaultBeanNameGenerator  、 AnnotationBeanNameGenerator

    }
}
